package com.example.designmodule.observer;

/**
 * @Author: Dijah
 * @Date: 2022/2/8 14:50
 * @Desc:
 */
public class BinaryObserver extends Observer {

    //在构造方法中订阅主题
    public BinaryObserver(Subject subject){
        this.subject=subject;
        this.subject.attach(this);
    }

    @Override
    public void update() {
        String result = Integer.toBinaryString(subject.getState());
        System.out.println("订阅的数据发生变化，新的数据处理为二进制为："+result);
    }
}
